/*jQuery.toJSON*/
(function($){var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};$.toJSON=typeof JSON==='object'&&JSON.stringify?JSON.stringify:function(o){if(o===null){return'null';}
var type=typeof o;if(type==='undefined'){return undefined;}
if(type==='number'||type==='boolean'){return''+o;}
if(type==='string'){return $.quoteString(o);}
if(type==='object'){if(typeof o.toJSON==='function'){return $.toJSON(o.toJSON());}
if(o.constructor===Date){var month=o.getUTCMonth()+1,day=o.getUTCDate(),year=o.getUTCFullYear(),hours=o.getUTCHours(),minutes=o.getUTCMinutes(),seconds=o.getUTCSeconds(),milli=o.getUTCMilliseconds();if(month<10){month='0'+month;}
if(day<10){day='0'+day;}
if(hours<10){hours='0'+hours;}
if(minutes<10){minutes='0'+minutes;}
if(seconds<10){seconds='0'+seconds;}
if(milli<100){milli='0'+milli;}
if(milli<10){milli='0'+milli;}
return'"'+year+'-'+month+'-'+day+'T'+
hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
if(o.constructor===Array){var ret=[];for(var i=0;i<o.length;i++){ret.push($.toJSON(o[i])||'null');}
return'['+ret.join(',')+']';}
var name,val,pairs=[];for(var k in o){type=typeof k;if(type==='number'){name='"'+k+'"';}else if(type==='string'){name=$.quoteString(k);}else{continue;}
type=typeof o[k];if(type==='function'||type==='undefined'){continue;}
val=$.toJSON(o[k]);pairs.push(name+':'+val);}
return'{'+pairs.join(',')+'}';}};$.evalJSON=typeof JSON==='object'&&JSON.parse?JSON.parse:function(src){return eval('('+src+')');};$.secureEvalJSON=typeof JSON==='object'&&JSON.parse?JSON.parse:function(src){var filtered=src.replace(/\\["\\\/bfnrtu]/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered)){return eval('('+src+')');}else{throw new SyntaxError('Error parsing JSON, source is not valid.');}};$.quoteString=function(string){if(string.match(escapeable)){return'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==='string'){return c;}
c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
return'"'+string+'"';};})(jQuery);
/*jQuery.toJSON*/
window._adUrlBase = "http://ads.hearst.com.cn/";
$(document).ready(function(){
    if (false || typeof(console)==='undefined') console = {log:function(){}};
    var mkws, adbase, timeout;
    $.getJSON(window._adUrlBase+'index.php?do=launch.getKeywordsAds&callback=?', function(d){//kw=>ad mapping data from server
        mkws    = d.mkws || '';
        adbase  = d.adbase || {'adsame':'http://hfm.adsame.com/s?z=hfm&', 'hd':window._adUrlBase+'index.php?do=launch.getKWHTML&'};
        timeout = d.timeout || 700;
        mkws    = d;//for demo only, should be updated later
        var mainbox = $('.content-wrap, #main_div, .article-content, #div_text');
        if (mainbox.length!=1 || typeof(mkws)!='object') return;//check input data
        var mainbox_html = mainbox.html();
        var special_str = "_@x@_";//should be very special
        var highlight_span_style = "style='font-family:Verdana,宋体,sans-serif; color:#F59599;color:#f59599; border-bottom:1px dashed #f59599;cursor:pointer;font-weight:normal;'";//font-style: italic;background-color: yellow;color:#06F;'";
        for (k in mkws) {//low performance here 
//            if (-1 == mainbox_html.indexOf(k)) continue;//iI ?
        	if (-1 == mainbox_html.toLowerCase().indexOf(k)) continue;
            var escape_in_tag_k = new RegExp('((title|alt)=".*?'+k+')','gi');
            var normal_k = new RegExp('('+k+')(?!'+special_str+')','gi');
            mainbox_html = mainbox_html.replace(escape_in_tag_k, "$1"+special_str).replace(normal_k, "<span class='hd_kw_ads_span' ref id='"+mkws[k]+"' "+highlight_span_style+">$1</span>");
        }
        mainbox_html = mainbox_html.replace(new RegExp(special_str,'gi'), '');//clean our tag
        var matches = {};
        mainbox.html(mainbox_html);
        $('span.hd_kw_ads_span').each(function(){
            var kw = $(this).text().toLowerCase();
            if (typeof(matches[kw])!="undefined") {
                matches[kw]['count'] += 1;
                if (matches[kw]['count']>5) $(this).attr({'class':'','style':''});//first 5
            } else {
                matches[kw] = {'count': 1, 'adid': encodeURIComponent(mkws[kw])};
            }
        });
        (new Image).src = window._adUrlBase+"d/hd_pv.php?_r="+Math.random();//pv log
        setTimeout(function(){(new Image).src = window._adUrlBase+'d/log.php?type=kw_match&matches='+jQuery.toJSON(matches);}, 1000);//waiting for cookie from pv log
        $('span.hd_kw_ads_span').mouseover(function(e){
            var span = $(this);
            var xx = e.originalEvent.pageX || e.originalEvent.x || e.originalEvent.layerX || 0;//where mouse over 
            var yy = e.originalEvent.pageY || e.originalEvent.y || e.originalEvent.layerY || 0; 
            //var css = {'top':(6+yy)+'px', 'left':(xx-40)+'px'};//position
            var css = {'top':span.position().top+span.height()+4+'px', 'left':span.position().left+'px'};//position
            if (span.attr('ref')!='') {
                var iframe = $('#'+span.attr('ref'));
                if (iframe.attr('ref')) {
                    clearTimeout(iframe.attr('ref'));
                    return iframe.show(300);//already have a iframe
                }
                return iframe.css(css).show(300);//already have a iframe
            }
            var id = 'h'+(''+Math.random()).replace('\.','_');//random id
            var kw = span.text();
            var pos1 = $('span.hd_kw_ads_span').index(span);
            var pos2 = $('span.hd_kw_ads_span[id="'+span.attr('id')+'"]').index(span);
            var adid = mkws[span.text().toLowerCase()];
            var adurl = (adid.indexOf('=HD')>0 ? adbase.hd : adbase.adsame) + adid;
            var attr = {'src':window._adUrlBase+'d/ad'+(adid.indexOf('&es=1')>0 ? '_es' : '')+'.html?kw='+encodeURIComponent(kw)+'&adurl='+encodeURIComponent(adurl)+'&pos1='+pos1+'&pos2='+pos2+'&adid='+encodeURIComponent(adid)+'&_r='+Math.random(), 'id':id};//apply id
            mainbox.append($('<iframe style="position:absolute; border:0px; display:none; z-index:9999" border=0 frameborder=0 width=210 height=200></iframe>').attr(attr).css(css));//draw iframe
            span.attr('ref',id);//save current iframe id
            var iframe = $('#'+id);
            setTimeout(function(){iframe.show(300);}, 600);
            span.mouseout(function(){
                var tHandle = setTimeout(function(){
                    iframe.hide();
                }, timeout);
                iframe.attr('ref',tHandle);
            });
            iframe.mouseover(function(){
                clearTimeout(iframe.attr('ref'));
            }).mouseout(function(){
                var tHandle = setTimeout(function(){
                    iframe.hide();
                }, timeout);
                iframe.attr('ref',tHandle);
            });
        });
    });
    $.getJSON(window._adUrlBase+"index.php?do=pic.getPicAds&callback=?",function(d){//img ads, condition=>ad mapping data from server
        $('#arrow_shadow_left, #arrow_shadow_right').remove();
        var _u = function (a,b) {
            if (a==b) return true;
            if (a.length==0 || b.length==0) return false;
            var al = a.length;
            var bl = b.length;
            for (var i=0;i<al;i++) {
                for(var j=0;j<al;j++) {
                    if (a[i]==b[j]) return true;
                }
            }
            return false;
        }
        var _x = function (s) {
            var rtn = {};
            var a = s.split(';');
            var al = a.length;
            for (var i=0;i<al;i++) {
                if (a[i]=='') continue;
                var kv = a[i].split(':');
                if (kv.length==1) continue;
                rtn[kv[0]] = kv[1].split(',');
                if (rtn[kv[0]].length==1) rtn[kv[0]] = kv[1].split(' ');
            }  
            return rtn;
        }  
        var _m = function (sd,sc) {
            var c = _x(sc);
            var d = _x(sd);
            for (var i in c) {
                if (typeof(d[i])=='undefined' || !_u(d[i],c[i])) return false;
            }  
            return true;
        }
        var animate_time = 250;
        var animate_delay = 70;
        var hide_ad = function (img_ad, callback){
        	console.log('hide_ad');
        	if (img_ad.attr('curr_div')=='hd_img_ad_cdiv'){
        		img_ad.find('.hd_img_ad_cdiv').hide();
        		return;
        	}        	
        	var directs =[
        		['0px','100px'],
        		['0px','100px'],
        		['0px','-100px'],
        		['0px','0px']
        	]
        	var tpl = img_ad.attr('tpl');
        	var direct = directs[tpl];
        	if (direct[0]==direct[1]){
        		img_ad.find('.hd_img_ad_div').hide();
        		return;
        	}
        	
            img_ad.find('.hd_img_ifr_div').stop(true).css({'margin-top': direct[0]}).animate({'margin-top': direct[1]}, animate_time, 'linear', function(){
                img_ad.find('.hd_img_ad_div').hide();
                if (typeof(callback)=='function'){
                	callback();
                }
            });
        };
        var show_ad = function (img_ad, callback){
        	console.log('show_ad');
        	if (img_ad.attr('curr_div')=='hd_img_ad_cdiv'){
        		img_ad.find('.hd_img_ad_cdiv').show().end().find('.hd_img_ad_odiv').hide();
        		return;
        	}
        	var directs =[
        		['100px','0px'],
        		['100px','0px'],
        		['-100px','0px'],
        		['0px','0px']
        	]
        	var tpl = img_ad.attr('tpl');
        	var direct = directs[tpl];
        	img_ad.find('.hd_img_ad_cdiv').hide();
        	img_ad.find('.hd_img_ad_odiv').show();
        	img_ad.find('.hd_img_ad_div').show();
        	if (direct[0]==direct[1]){
        		return;
        	}
        	
            img_ad.find('.hd_img_ifr_div').stop(true).css({'margin-top': direct[0]}).animate({'margin-top': direct[1]}, animate_time, 'linear', function(){
                if (img_ad.find('.hd_img_clo_div').css('width')=='40px') {
                    img_ad.find('.hd_img_clo_div').css({'width':'41px'});//bug fix
                } else {
                    img_ad.find('.hd_img_clo_div').css({'width':'40px'});//bug fix
                }
                if (typeof(callback)=='function'){
                	callback();
                }
            });
        };
        var t_ad_leave = t_ad_enter = t_img_leave = t_img_enter = 0;
        var target_mouseenter = function(img_ad){
			//console.log('target_img_mouseenter',t_ad_leave, t_ad_enter, t_img_leave, t_img_enter);
            if (t_img_enter!==0) {return;}
            if (t_ad_leave!==0) {clearTimeout(t_ad_leave); t_ad_leave = 0; return;}
            if (t_img_leave!==0) {clearTimeout(t_img_leave); t_img_leave = 0; return;}
            t_img_enter = setTimeout(function(){t_img_enter=0;show_ad(img_ad);}, animate_delay);
			console.log('img_enter');
        };
        var target_mouseleave = function(img_ad){
			//console.log('target_img_mouseleave',t_ad_leave, t_ad_enter, t_img_leave, t_img_enter);
            if (t_img_leave!==0) {return;}
            if (t_ad_enter!==0) {clearTimeout(t_ad_enter); t_ad_enter = 0; return;}
            if (t_img_enter!==0) {clearTimeout(t_img_enter); t_img_enter = 0; return;}
            t_img_leave = setTimeout(function(){t_img_leave=0;hide_ad(img_ad);}, animate_delay);
			console.log('img_leave');
        };
        var ad_mouseenter = function(img_ad){
			//console.log('target_ad_mouseenter',t_ad_leave, t_ad_enter, t_img_leave, t_img_enter);
            if (t_ad_enter!==0) return;
            if (t_ad_leave!==0) {clearTimeout(t_ad_leave); t_ad_leave = 0; return;}
            if (t_img_leave!==0) {clearTimeout(t_img_leave); t_img_leave = 0; return;}
            t_ad_enter = setTimeout(function(){t_ad_enter=0;show_ad(img_ad);}, animate_delay);
			console.log('ad_enter');
        };
        var ad_mouseleave = function(img_ad){
			//console.log('target_ad_mouseleave',t_ad_leave, t_ad_enter, t_img_leave, t_img_enter);
            if (t_ad_leave!==0) return;
            if (t_ad_enter!==0) {clearTimeout(t_ad_enter); t_ad_enter = 0; return;}
            if (t_img_enter!==0) {clearTimeout(t_img_enter); t_img_enter = 0; return;}
            t_ad_leave = setTimeout(function(){t_ad_leave=0;hide_ad(img_ad);}, animate_delay);
			console.log('ad_leave');
        };

        var _ad_html = function(img_ad_id,url,ad_width,tpl){
        	ad_width=parseInt(ad_width);
        	var ad_heights = [ 100, 100, 100, 62 ];
        	var ad_height = ad_heights[ tpl ];
            var iframe_url = url+"&r="+Math.random()+"#target_width="+ad_width+'&refer='+location.href;
           	var iframe_open_img = window._adUrlBase+"d/img/open_btn.png";
           	var html = [];
           	//border:1px dotted red;height:100px;
       		html.push('<div id="'+img_ad_id+'" style="width:'+ad_width+'px;">');
       		html.push('	<div class="hd_img_ad_odiv" style="text-align:center;text-indent:0em;">');
       		html.push('		<div class="hd_img_ad_div" style="width:'+ad_width+'px;height:'+ad_height+'px;margin-top:-'+ad_height+'px;overflow:hidden;">');
       		html.push('			<div class="hd_img_ifr_div" style="cursor:pointer">');
       		html.push('				<div class="hd_img_ad_col" title="关闭广告" style="cursor:pointer;position:absolute;margin-left:'+(ad_width-40)+'px;margin-top:60px;width:40px;height:13px;"> </div>');
       		html.push('				<iframe height="'+ad_height+'" frameborder="0" width="'+ad_width+'" scrolling="no" style="left:0px;top:0px;padding:0px;margin:0px;" allowtransparency="true" marginwidth="0" marginheight="0" hspace="0" vspace="0" src="'+iframe_url+'"></iframe>');
       		html.push('			</div>');
       		html.push('		</div>');
       		html.push('	</div>');
       		html.push('	<div class="hd_img_ad_cdiv" style="text-align:center;display:none">');
       		html.push('		<div style="width:'+ad_width+';margin-right:auto;margin-left:auto;height:0px;margin-top:0px;overflow:hidden;text-align:center">');
       		html.push('			<div class="hd_img_ad_oimg" title="打开广告" style="background:url(\''+iframe_open_img+'\') no-repeat;cursor:pointer;position:absolute;margin-left:'+(ad_width-70)+'px;margin-top:-13px;width:70px;height:13px;"></div>');
       		html.push('		</div>');
       		html.push('	</div>');
       		html.push('</div>');
       		var img_ad = $(html.join('')).attr('tpl',tpl);
       		//img_ad.find('div').css('border','1px dotted red');
       		if (tpl!=3) {
       			img_ad.css({'margin-right':'auto','margin-left':'auto','text-align':'center'});
	       		img_ad.find('.hd_img_ad_col').click(function(){
		           	img_ad.attr('curr_div','hd_img_ad_cdiv');
		           	show_ad(img_ad);
		        });
		        img_ad.find('.hd_img_ad_cdiv').click(function(){
		           	img_ad.attr('curr_div','hd_img_ad_odiv');
		           	show_ad(img_ad);
		        });
	        }
	        img_ad.bind('mouseenter', function(){ad_mouseenter(img_ad);}).bind('mouseleave', function(){ad_mouseleave(img_ad);});
	        if (tpl==1){
	        	img_ad.find('.hd_img_ad_col').css('margin-top','87px');//.css('border','1px dotted red');
	        } else if (tpl==2){
	        	img_ad.find('.hd_img_ad_col').css('margin-top','0px');//.css('border','1px dotted red');
	        	var mheight = $('#big_img_bar').css('height');
        		img_ad.find('.hd_img_ad_div').css('margin-top','-'+mheight);
        		img_ad.find('.hd_img_ad_oimg').css('margin-top','-'+mheight);
	        } else if (tpl==3) {
	        	img_ad.css('position','absolute');
	        	img_ad.find('.hd_img_ad_col').remove();
	        	img_ad.find('.hd_img_ad_cdiv').remove();
	        	img_ad.find('.hd_img_ad_div').css('margin-top','0px');//.css('overflow','auto');
	        }
	        return img_ad;
        }
        var _draw_ads = {}; 
        _draw_ads[0] = function (target_img, url, showmenow) {
        	//console.log('img over', target_img);
        	var img_ad_id = 'hd_img_ad_'+($('img[data-mce-class]').index(target_img)+100);
        	var img_ad = $('#'+img_ad_id);
        	if (img_ad.length==0){
        		img_ad.remove();
        		target_img.unbind('mouseenter mouseover mouseleave');
        	}
    		var ad_width = target_img.css('width');
    		img_ad = _ad_html(img_ad_id,url,ad_width,0);
    		img_ad.insertAfter(target_img);//.find('*').css({'border':'1px dotted red'});
        	//console.log(img_ad);
        	if (!showmenow) {
                hide_ad(img_ad,function(){img_ad.show();console.log('hide by showmenow', target_img);});
            } else {
                img_ad.show();
            }
            target_img.unbind('mouseenter mouseover mouseleave')
            	.bind('mouseenter', function(){target_mouseenter(img_ad);})
            	.bind('mouseleave', function(){target_mouseleave(img_ad);});
            console.log('img_ads_drawed - added: ', img_ad_id);
        }
        _draw_ads[1] = function(img_bar,url,tpl) {
        	var target_img = img_bar.find("img[data-mce-class]:visible");
        	var img_ad_id = 'hd_img_ad_'+($('img[data-mce-class]').index(target_img)+100);
        	var img_ad = $('#'+img_ad_id);
        	if (img_ad.length==0){
        		var ad_width = img_bar.css('width');
        		img_ad = _ad_html(img_ad_id,url,ad_width,tpl);
        		img_ad.insertAfter(img_bar);
        	}
        	img_ad.show();
        	img_bar.unbind('mouseenter mouseleave mousemove click')
        		.bind('mouseenter', function(){target_mouseenter(img_ad);})
        		.bind('mouseleave', function(){target_mouseleave(img_ad);});
        	img_bar.attr('img_ads_drawed',img_ad_id);
            console.log('img_ads_drawed'+tpl+' - added: ', img_ad_id);
        }
        _draw_ads[2] = function(img_bar,url,tpl) {
        	_draw_ads[1](img_bar,url,tpl);
        }
		var hide_timer = 0;
		var show_timer = 0;
        _draw_ads[3] = function(img_bar,url,tpl,eve) {
        	clearTimeout( hide_timer );
        	var target_img = img_bar.find("img[data-mce-class]:visible");
        	var matched_data = target_img.attr('hd_img_ad_matched_data');
        	var out_url = decodeURIComponent((matched_data.match(/url=(.+?)&/i)[1]+'').replace(/\+/g, '%20'));
        	var img_ad_id = 'hd_img_ad_'+($('img[data-mce-class]').index(target_img)+100);
        	var img_ad = $('#'+img_ad_id);
        	if (img_ad.length==0){
        		var ad_width = 334;
        		img_ad = _ad_html(img_ad_id,url,ad_width,tpl);
        		img_ad.appendTo('body');
        		//img_ad.insertAfter(img_bar);
        	}
        	img_ad.show().find('.hd_img_ad_odiv').show().find('.hd_img_ad_div').show();
        	img_bar.css('cursor','pointer').unbind('mouseleave mousemove click')
        	.bind('mouseenter', function(){target_mouseenter(img_ad);})
        	.bind('mouseleave', function(){target_mouseleave(img_ad);})
        	.bind('mousemove', function(e){
        		var sl = $(window).scrollLeft();
				var st = $(window).scrollTop();
        		img_ad.css({'left':e.clientX+sl+8-50,'top':e.clientY+st-50+20});
        		console.log('img_bar,sl='+sl,'st='+st,'e.clientX='+e.clientX,'e.clientY='+e.clientY);
        	}).bind('click',function(){
        		window.open(out_url);
				$.getJSON(window._adUrlBase+'d/log.php?callback=?', {"type":"click", "page_url":location.href, "adurl": location.href, "ourl":out_url}); 
        	});
        	img_bar.attr('img_ads_drawed',img_ad_id);
            console.log('img_ads_drawed'+tpl+' - added: ', img_ad_id);
        }
        var _bar_over = function(e) {
        	var img_bar = $(this);
        	if (img_bar.attr('img_ads_drawed')!=null){
        		$('#'+img_bar.attr('img_ads_drawed')).hide();
        	}
        	var target_img = img_bar.find("img[data-mce-class]:visible");
        	if (target_img.length==0 || target_img.attr('hd_img_ad_matched_data')==null){
        		return;
        	}
        	var url = window._adUrlBase+'index.php?do=pic.getPicAdsHTML&'+target_img.attr('hd_img_ad_matched_data');
        	var tpl = parseInt( target_img.attr('hd_img_ad_tpl') );
        	if (typeof(_draw_ads[tpl])=='function') {
        		_draw_ads[tpl](img_bar,url,tpl,e);
        	}
        }
        var matches = {};
        for (cond in d) {
            //console.log(cond);
            //console.log(d[cond]);
            $('img[data-mce-class]').each(function(){
                var img = $(this);
                var data = typeof(img.attr('hd_img_ad_data')) == 'undefined' ? "" : img.attr(s);
                if (data == 'no_data_assigned') return false;
                if (data == '') {
                    if ("undefined"!=typeof(img.attr("data-mce-class"))) data += "class:"+img.attr("data-mce-class")+";";
                    if ("undefined"!=typeof(img.attr("data-mce-brand"))) data += "brand:"+img.attr("data-mce-brand")+";";
                    if ("undefined"!=typeof(img.attr("data-mce-tags"))) data += "tag:"+img.attr("data-mce-tags")+";";
                    if ("undefined"!=typeof(img.attr("data-mce-channel"))) data += "channel:"+img.attr("data-mce-channel")+";";
                    else if (img.parents('div[channel]')) data += "channel:"+img.parents('div[channel]').attr('channel')+";"; 
                    if (data == '') {
                        img.attr('hd_img_ad_data', 'no_data_assigned');
                        return false;
                    }
                }
                //console.log( 'img_data:' + data );
                var matched_data = d[cond];
                if (_m(data,cond)) {
                    console.log('matched: ' + matched_data );
                    if (typeof(matches[cond])!="undefined") {
                        matches[cond]['count'] += 1;
                    } else {
                        matches[cond] = {'count': 1, 'hdid': matched_data.match(/id=(.+?)&/i)[1], 'tpl': matched_data.match(/tpl=(.+?)&/i)[1] };
                    }
                    //console.log( matches[cond] );
                    if (matches[cond].tpl==0)
                    {
	                    if (img.filter(":hidden").length > 0) {//lazy load for hidden images
	                        img.bind('mouseover', function(){
	                            img.unbind('mouseover');
	                            _draw_ads[0](img, window._adUrlBase+'index.php?do=pic.getPicAdsHTML&'+matched_data, true);
	                        });
	                    } else {//current display image
	                        _draw_ads[0](img, window._adUrlBase+'index.php?do=pic.getPicAdsHTML&'+matched_data, false);
	                        img.load(function(){
	                            img.load(function(){});
	                            console.log('target_img.load');
	                            _draw_ads[0](img, window._adUrlBase+'index.php?do=pic.getPicAdsHTML&'+matched_data, false);
	                        });
	                    }
                    }
                    else
                    {
                    	img.attr('hd_img_ad_matched_data', matched_data);
                    	img.attr('hd_img_ad_tpl', matches[cond].tpl);
                    }
                }
            });
        }
      	$('#big_img_bar').bind('mouseenter', _bar_over);
        setTimeout(function(){(new Image).src = window._adUrlBase+'d/log.php?type=img_match&matches='+jQuery.toJSON(matches);}, 1000);//waiting for cookie from pv
    });
}); 
